class Solution:
    def numSubseq(self, nums: list, target: int) -> int:
        MOD = 10**9 + 7
        cnt = 0
        left = 0
        right = len(nums) - 1
        nums.sort()
        while left <= right:
            if nums[left] + nums[right] <= target:
                cnt += 2**(right - left)
                cnt %= MOD
                left += 1
            else:
                right -= 1
        return cnt
